#ifndef MODELMANAGER_H
#define MODELMANAGER_H

#include "IModel.h"
#include <vector>
#include <string>

#ifdef __cplusplus
extern "C" {
#endif

class ModelManager
{
  public:

    /// Destructor
    __declspec(dllexport) ~ModelManager() {
      for(ModelVector::reverse_iterator It = m_Models.rbegin();
          It != m_Models.rend();
          ++It)
        delete *It;
    }

    /// Allows plugins to add new graphics drivers
    __declspec(dllexport) void addModel(std::auto_ptr<IModel> M) {
      m_Models.push_back(M.release());
    }

    /// Get the total number of registered graphics drivers
    __declspec(dllexport) size_t getModelCount() const {
      return m_Models.size();
    }
    /// Access a driver by its index
    __declspec(dllexport) IModel &getModel(size_t Index) {
      return *m_Models.at(Index);
    }

	__declspec(dllexport) void configAll(asIScriptEngine *engine)
	{
      for(ModelVector::reverse_iterator It = m_Models.rbegin();
          It != m_Models.rend();
          ++It)
	  {
		  (*It)->config(engine);
	  }
	}
  private:
    /// A vector of graphics drivers
    typedef std::vector<IModel *> ModelVector;
    ModelVector m_Models; ///< All available graphics drivers
};

#ifdef __cplusplus
}
#endif

#endif